//
//  CategoryApi.swift
//  Pods
//
//  Created by eme on 2017/4/10.
//
//

import UIKit
import Alamofire
import NetWorkCore

public enum CategoryApi{
    
    case getCategoryList()                                                          ///获取分类类型
    case getCategoryGoodList(pptype:String,ppturl:String,page:Int,length:Int)       ///获取分类商品
    case getCategoryGood(page:Int,length:Int,pptid:String)
    
}


extension CategoryApi:TargetType{
    //设置路径
    public var path:String{
        switch self {
        case .getCategoryList:
            return "/glPfproductType/ptypelist.json"
        case .getCategoryGoodList(_,_,_,_):
            return "/seProduct/productlistbypftype.json"
        case .getCategoryGood(page: _, length: _, pptid: _):
            return "/seProduct/productlistbypftypeid.json"
        }
    }
    //请求方式
    public var method: HTTPMethod{
        switch self {
        default:
            return .post
        }
    }
    //请求参数
    public var parameters:Parameters?{
        switch self {
        case let .getCategoryGoodList(pptype,ppturl,page,length):
            return ["pptype":pptype,"ppturl":ppturl,"page":page,"length":length]
        case let .getCategoryGood(page,length,pptid):
            return ["page":page,"length":length,"pptid":pptid]
        default:
            return nil
        }
    }
}
